package com.jiezhuo.utils;

public class StringUtils {
    // 身份证号码 脱敏
    public static String maskID(String id) {
        if (id == null || (id.length() != 18 && id.length() != 15)) {
            return id;
        }
        return id.replaceAll("^(\\d{6})(\\d{8})(\\d{3})", "$1********$3");
    }

    public static Boolean isStringExist(String str) {
        if (str == null || "".equals(str)) {
            return false;
        }
        return true;
    }

    public static Boolean isStringNotExist(String str) {
        return !isStringExist(str);
    }

    // 手机号码脱敏
    public static String maskPhoneNumber(String phoneNumber) {
        if (phoneNumber == null || phoneNumber.length() != 11) {
            return phoneNumber;
        }
        return phoneNumber.substring(0, 3) + "*******" + phoneNumber.substring(7);
    }


}
